package imread;

import java.util.Properties;

import javax.mail.Message.RecipientType;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class testa {
     
	 /** 
     * @param args 
     */  
  
  
    public static void main(String[] args) throws Exception  
    {  
    	String userName = "service@iqinshu.com";  
        // 下面是邮箱的密码  
        String password = "QinshuRg2fTRE$JH3";  
        String host = "smtp.exmail.qq.com";  
        String protocal = "smtp";  
        String to = "15869155962@139.com";  
        Properties props = new Properties();  
        props.put("mail.smtp.auth", "true");  
        Session session = Session.getDefaultInstance(props);  
        MimeMessage message = new MimeMessage(session);  
        message.setRecipients(RecipientType.TO, to);  
        message.setFrom(new InternetAddress(userName));  
        message.setSubject("测试邮件");  
        message.setText("Hello World ", "UTF-8");  
        Transport transport = session.getTransport(protocal);  
        transport.connect(host, userName, password);  
        transport.sendMessage(message, message.getAllRecipients());  
        System.out.println("--------send mail success-------------"); 
      /*  String userName = "xusaike@jndl.mobi";  
        // 下面是邮箱的密码  
        String password = "abc3732143";  
        String host = "smtp.qq.com";  
        String protocal = "smtp";  
        String to = "15869155962@139.com";  
        Properties props = new Properties();  
        props.put("mail.smtp.auth", "true");  
        Session session = Session.getDefaultInstance(props);  
        MimeMessage message = new MimeMessage(session);  
        message.setRecipients(RecipientType.TO, to);  
        message.setFrom(new InternetAddress(userName));  
        message.setSubject("测试邮件");  
        message.setText("Hello World ", "UTF-8");  
        Transport transport = session.getTransport(protocal);  
        transport.connect(host, userName, password);  
        transport.sendMessage(message, message.getAllRecipients());  
        System.out.println("--------send mail success-------------");  */
    }  
}